package com.cxd.base.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cxd.base.common.exception.CxdException;
import com.cxd.base.mapper.read.RManageMapper;
import com.cxd.base.service.ManageService;
import com.cxd.base.util.BeanTools;

/**
 * @author wtj
 * @date 2015年12月1日 下午4:16:20
 * @company CXD
 * @version [Copyright (c) 2015 V001]
 */
@Service("manageService")
public class ManageServiceImpl implements ManageService {
	@Resource
	RManageMapper rmanageMapper;
	
	
	@Resource
	public BeanTools db;

	public void setDb(BeanTools db) {
		this.db = db;
	}

	/**
	 * 
	  * @方法说明:
	  *
	  * @author 王统江 
	  * @return int 
	  * @date 2013-12-22 下午12:38:08
	 */
	public int add(Object object) {
		try {
			return db.add(object);
		} catch (CxdException e) {
			throw e;
		}
	}

	/**
	 * 批量删除数据
	 */
	public boolean delListData(String delDateStr){
//		try {
//			String[] delDateStrs = delDateStr.split(";");
//			for(int i=0;i<delDateStrs.length;i++){
//				String[] delDates = delDateStrs[i].split(":");
//				db.delLog(delDates[0],"id,version",delDates[1]+","+delDates[2]);
//			}
			return true;
//		} catch (CxdException e) {
//			throw e;
//		}
	}
	public int updateStatus(String tableName,String id,String status){
		return db.update("UPDATE "+tableName+" SET STATUS="+status+" WHERE ID='"+id.trim()+"'");
	}
	
	public int updateById(String tableName,String id,String field,String value){
		return db.update("UPDATE "+tableName+" SET "+field+"="+value+" WHERE ID='"+id.trim()+"'");
	}
}

